from typing import List, Optional, Union
from pydantic import BaseModel, Field, Json

from bases.schame import PaginationParams, PaginationViewSchema

# 全部字段
class PermissionSchema(BaseModel):
    name: str = Field(..., description="名称")
    value: str = Field(..., description="值")
    type: int = Field(..., description=" 类型")
    description: str = Field(..., description="描述")
# 新增
class PermissionCreateSchema(BaseModel):
    pass
# 修改
class PermissionUpdateSchema(BaseModel):
    pass
# 分页单条
class PermissionItemSchema(BaseModel):
    pass

# 分页
class FilterParams(BaseModel):
    name: Optional[str] = Field(None, description="权限")
    value: Optional[str] = Field(None, description="值")
    type: Optional[int] = Field(None, description=" 类型")

class PermissionPaginationParams(PaginationParams):
    filter: Optional[Union[Json, FilterParams]] = Field(default={}, description="过滤条件")

class PermissionPaginationSchema(PaginationViewSchema):
    data: List[PermissionSchema] = Field(..., description="列表")
